﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Derbster.Domain
{
    public class Team : IEquatable<Team>
    {
        [ContractVerification(false)]
        internal Team()
        {
            
        }

        public Team(string name)
        {
            Contract.Requires(!string.IsNullOrWhiteSpace(name));

            Name = name;
            Skaters = new HashSet<Skater>();
        }

        public Team(string name, string location)
        {
            Contract.Requires(!string.IsNullOrWhiteSpace(name));
            Contract.Requires(!string.IsNullOrWhiteSpace(location));

            Name = name;
            Skaters = new HashSet<Skater>();
        }

        public Team(string name, HashSet<Skater> skaters)
        {
            Contract.Requires(!string.IsNullOrWhiteSpace(name));
            Contract.Requires(skaters != null);

            Name = name;
            Skaters = skaters;
        }

        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int TeamId { get; internal set; }
        public string Name { get; internal set; }
        public League League { get; internal set; }
        public string Location { get; internal set; }
        public HashSet<Skater> Skaters { get; internal set; }
        public bool Equals(Team other)
        {
            if (other == null) return false;

            return this.TeamId == other.TeamId;
        }
    }
}
